<template>
  <!-- 退出登陆 -->
  <div class="login-out">
    <el-button class="login-out-button" type="danger" round @click="loginOut">退出登陆</el-button>
  </div>
</template>

<script>
import { ElMessage, ElMessageBox } from 'element-plus'
export default {
  name: 'GSetting',
  methods: {
    loginOut () {
      ElMessageBox.confirm(
        '确定要退出吗?',
        '',
        {
          confirmButtonText: '确认',
          cancelButtonText: '再玩一下',
          type: 'warning',
        }
      )
        .then(() => {
          this.$axios('/user/loginout').then((res) => {
            if (res.flag) {
              ElMessage({
                message: res.msg,
                grouping: true,
                type: 'success',
                duration: 2000,
              })
              this.$router.push('/login')
            }
          })
        })
        .catch(() => {

        });
    },
  },
}
</script>

<style scoped>
.login-out {
  text-align: center;
}
.login-out-button {
  width: 50%;
}
</style>